package com.example.service;


import com.example.entity.ImageFiles;
import com.example.mapper.ImageFilesMapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * png文件表业务处理
 **/
@Service
public class ImageFilesService {

    @Autowired
    private ImageFilesMapper imageFilesMapper;

    /**
     * 新增
     */
    public void add(ImageFiles imageFiles) {
        imageFilesMapper.insert(imageFiles);
    }

    /**
     * 删除
     */
    public void deleteById(Integer id) {
        imageFilesMapper.deleteById(id);
    }

    /**
     * 批量删除
     */
    public void deleteBatch(List<Integer> ids) {
        for (Integer id : ids) {
            imageFilesMapper.deleteById(id);
        }
    }

    /**
     * 修改
     */
    public void updateById(ImageFiles imageFiles) {
        imageFilesMapper.updateById(imageFiles);
    }

    /**
     * 根据ID查询
     */
    public ImageFiles selectById(Integer id) {
        return imageFilesMapper.selectById(id);
    }

    /**
     * 查询所有
     */
    public List<ImageFiles> selectAll(ImageFiles imageFiles) {
        return imageFilesMapper.selectAll(imageFiles);
    }

    /**
     * 分页查询
     */
    public PageInfo<ImageFiles> selectPage(ImageFiles imageFiles, Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<ImageFiles> list = imageFilesMapper.selectAll(imageFiles);
        return PageInfo.of(list);
    }

    public ImageFiles selectBySeed(String seed) {
        return imageFilesMapper.selectBySeed(seed);
    }
}